home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha Extra 2004 January / CyberMycha Extra 1-2004 (Poland) (Disc 2).bin / Pippi / gmtr.dir / Internal_3_trScript.ls < prev    next >
Encoding:
Text File  |  2001-09-05  |  7.5 KB  |  293 lines

  1. property squareList, locList, squareListOccupation, computerSprites, userSprites, vicList, moveCounter, moveDimeCounter, moveThisOne, moveToThisSquare, playMode, whosNext, scoreCounter
  2. global autoMoveObject, sndObject
  3.  
  4. on new me
  5.   playMode = 2
  6.   vicList = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9], [1, 5, 9], [3, 5, 7]]
  7.   scoreCounter = [0, 0]
  8.   return me
  9. end
  10.  
  11. on initGame me
  12.   if (scoreCounter[1] + scoreCounter[2]) = 5 then
  13.     if scoreCounter[1] > scoreCounter[2] then
  14.       v = "p"
  15.     else
  16.       v = "t"
  17.     end if
  18.     go("out" & v)
  19.   else
  20.     whosNext = 0
  21.     moveCounter = 0
  22.     moveDimeCounter = 0
  23.     squareList = []
  24.     locList = []
  25.     squareListOccupation = [0, 0, 0, 0, 0, 0, 0, 0, 0]
  26.     computerSprites = []
  27.     userSprites = []
  28.   end if
  29. end
  30.  
  31. on computerMove me
  32.   moveCounter = moveCounter + 1
  33.   if moveCounter < 4 then
  34.     moveThisOne = moveCounter
  35.   else
  36.     moveThisOne = 0
  37.   end if
  38.   moveToThisSquare = 0
  39.   if random(playMode) = 1 then
  40.     check2onArow(me, computerSprites)
  41.   end if
  42.   if moveToThisSquare = 0 then
  43.     if random(playMode) = 1 then
  44.       check2onArow(me, userSprites)
  45.     end if
  46.   end if
  47.   if moveToThisSquare = 0 then
  48.     checkAny(me)
  49.   end if
  50.   repeat with n = 1 to squareList.count
  51.     if locList[n] = sprite(computerSprites[moveThisOne]).loc then
  52.       squareListOccupation[n] = 0
  53.       exit repeat
  54.     end if
  55.   end repeat
  56.   autoMove(autoMoveObject, sprite(computerSprites[moveThisOne]), moveToThisSquare)
  57.   sprite(computerSprites[moveThisOne]).loc = point(moveToThisSquare[1], moveToThisSquare[2])
  58.   updateStage()
  59.   checkSuccess(me)
  60. end
  61.  
  62. on success me
  63.   case playMode of
  64.     0:
  65.       if whosNext = 1 then
  66.         v = random(2) + 2
  67.         scoreCounter[1] = scoreCounter[1] + 1
  68.       else
  69.         v = random(2)
  70.         scoreCounter[2] = scoreCounter[2] + 1
  71.       end if
  72.     2:
  73.       if whosNext = 1 then
  74.         sndObject.respondSnd(1, 3, 1, 1)
  75.         scoreCounter[1] = scoreCounter[1] + 1
  76.       else
  77.         sndObject.respondSnd(1, 1, 1, 1)
  78.         scoreCounter[2] = scoreCounter[2] + 1
  79.       end if
  80.     1:
  81.       if whosNext = 1 then
  82.         sndObject.respondSnd(1, 4, 1, 1)
  83.         scoreCounter[1] = scoreCounter[1] + 1
  84.       else
  85.         sndObject.respondSnd(1, 2, 1, 1)
  86.         scoreCounter[2] = scoreCounter[2] + 1
  87.       end if
  88.   end case
  89.   if whosNext = 1 then
  90.     sprite(scoreCounter[1] + 30).getUp()
  91.   else
  92.     sprite(scoreCounter[2] + 40).getUp()
  93.   end if
  94.   repeat while soundBusy(2)
  95.   end repeat
  96.   if whosNext = 1 then
  97.     pSprites = userSprites
  98.   else
  99.     pSprites = computerSprites
  100.   end if
  101.   repeat with n = 1 to 3
  102.     sprite(pSprites[n]).locZ = sprite(pSprites[n]).spriteNum + 130
  103.   end repeat
  104.   repeat while sprite(pSprites[3]).rotation < 360
  105.     repeat with n = 1 to 3
  106.       sprite(pSprites[n]).rotation = sprite(pSprites[n]).rotation + 20
  107.     end repeat
  108.     updateStage()
  109.   end repeat
  110.   repeat with b = 1 to 3
  111.     repeat with n = 1 to 3
  112.       sprite(pSprites[n]).memberNum = sprite(pSprites[n]).memberNum + 1
  113.     end repeat
  114.     updateStage()
  115.     X = the ticks + 10
  116.     repeat while the ticks < X
  117.     end repeat
  118.     repeat with n = 1 to 3
  119.       sprite(pSprites[n]).memberNum = sprite(pSprites[n]).memberNum - 1
  120.     end repeat
  121.     updateStage()
  122.     X = the ticks + 10
  123.     repeat while the ticks < X
  124.     end repeat
  125.   end repeat
  126.   repeat with n = 1 to 3
  127.     sprite(pSprites[n]).locZ = sprite(pSprites[n]).spriteNum
  128.   end repeat
  129.   whosNext = 0
  130.   repeat with n = 1 to 3
  131.     autoMove(autoMoveObject, sprite(computerSprites[n]), sprite(computerSprites[n]).firstPos)
  132.   end repeat
  133.   repeat with n = 1 to 3
  134.     autoMove(autoMoveObject, sprite(userSprites[n]), sprite(userSprites[n]).firstPos)
  135.   end repeat
  136.   go(1)
  137. end
  138.  
  139. on checkSuccess me
  140.   success = 0
  141.   if whosNext = 1 then
  142.     player = userSprites
  143.   else
  144.     player = computerSprites
  145.   end if
  146.   repeat with vic = 1 to 8
  147.     spriteCount = 0
  148.     repeat with sprites = 1 to 3
  149.       repeat with n = 1 to 3
  150.         if sprite(player[sprites]).loc = locList[vicList[vic][n]] then
  151.           spriteCount = spriteCount + 1
  152.           if spriteCount = 3 then
  153.             exit repeat
  154.           end if
  155.         end if
  156.       end repeat
  157.       if spriteCount = 3 then
  158.         exit repeat
  159.       end if
  160.     end repeat
  161.     if spriteCount = 3 then
  162.       success = 1
  163.       exit repeat
  164.     end if
  165.   end repeat
  166.   if success = 1 then
  167.     success(me)
  168.   else
  169.     whosNext = whosNext * -1
  170.   end if
  171. end
  172.  
  173. on checkAny me
  174.   if moveThisOne = 0 then
  175.     moveThisOne = random(3)
  176.   end if
  177.   hit = 0
  178.   repeat while hit = 0
  179.     v = random(9)
  180.     if squareListOccupation[v] = 0 then
  181.       hit = v
  182.       squareListOccupation[v] = 1
  183.       exit repeat
  184.     end if
  185.   end repeat
  186.   moveToThisSquare = squareList[hit]
  187. end
  188.  
  189. on check2onArow me, pplayer
  190.   success = 0
  191.   player = pplayer
  192.   repeat with vic = 1 to 8
  193.     spriteCount = 0
  194.     vicHits = []
  195.     playerSpriteHits = []
  196.     repeat with sprites = 1 to 3
  197.       repeat with n = 1 to 3
  198.         if sprite(player[sprites]).loc = locList[vicList[vic][n]] then
  199.           spriteCount = spriteCount + 1
  200.           vicHits[vicHits.count + 1] = n
  201.           playerSpriteHits[playerSpriteHits.count + 1] = sprites
  202.           if spriteCount = 2 then
  203.             lastOneEmpty = 1
  204.             repeat with H = 1 to 3
  205.               if (H <> vicHits[1]) and (H <> vicHits[2]) then
  206.                 lastOne = H
  207.                 exit repeat
  208.               end if
  209.             end repeat
  210.             if squareListOccupation[vicList[vic][lastOne]] = 1 then
  211.               lastOneEmpty = 0
  212.             end if
  213.             if lastOneEmpty = 1 then
  214.               exit repeat
  215.             end if
  216.           end if
  217.         end if
  218.       end repeat
  219.       if (spriteCount = 2) and (lastOneEmpty = 1) then
  220.         exit repeat
  221.       end if
  222.     end repeat
  223.     if (spriteCount = 2) and (lastOneEmpty = 1) then
  224.       success = 1
  225.       exit repeat
  226.     end if
  227.   end repeat
  228.   if success = 1 then
  229.     if lastOneEmpty = 1 then
  230.       moveToThisSquare = squareList[vicList[vic][lastOne]]
  231.       squareListOccupation[vicList[vic][lastOne]] = 1
  232.       if moveThisOne = 0 then
  233.         repeat with n = 1 to 3
  234.           if (n <> playerSpriteHits[1]) and (n <> playerSpriteHits[2]) then
  235.             moveThisOne = n
  236.             exit repeat
  237.           end if
  238.         end repeat
  239.       end if
  240.     end if
  241.   end if
  242. end
  243.  
  244. on reportUserMove me, pSprite, pSpriteRect, pSpriteOrigLoc
  245.   overLap = [0, 0]
  246.   repeat with n = 1 to squareList.count
  247.     if intersect(pSpriteRect, squareList[n]) > rect(0, 0, 0, 0) then
  248.       if squareListOccupation[n] = 0 then
  249.         v = intersect(pSpriteRect, squareList[n])
  250.         A = v[3] - v[1]
  251.         b = v[4] - v[2]
  252.         c = A + b
  253.         if c > overLap[2] then
  254.           overLap = [n, c]
  255.         end if
  256.       end if
  257.     end if
  258.   end repeat
  259.   if overLap = [0, 0] then
  260.     autoMove(autoMoveObject, sprite(pSprite), pSpriteOrigLoc)
  261.     updateStage()
  262.   else
  263.     moveDimeCounter = moveDimeCounter + 1
  264.     autoMove(autoMoveObject, sprite(pSprite), point(squareList[overLap[1]][1], squareList[overLap[1]][2]))
  265.     squareListOccupation[overLap[1]] = 1
  266.     repeat with g = 1 to squareList.count
  267.       if pSpriteOrigLoc = locList[g] then
  268.         squareListOccupation[g] = 0
  269.         exit repeat
  270.       end if
  271.     end repeat
  272.     updateStage()
  273.     checkSuccess(me)
  274.   end if
  275. end
  276.  
  277. on reportSquare me, squareRect
  278.   squareList[squareList.count + 1] = squareRect
  279.   if squareList.count = 9 then
  280.     repeat with n = 1 to 9
  281.       locList[n] = point(squareList[n][1], squareList[n][2])
  282.     end repeat
  283.   end if
  284. end
  285.  
  286. on reportComputer me, pSprite
  287.   computerSprites[computerSprites.count + 1] = pSprite
  288. end
  289.  
  290. on reportUser me, pSprite
  291.   userSprites[userSprites.count + 1] = pSprite
  292. end
  293.